#include "UI/Tests/Test.Application.h"

#undef  APP_NAME
#define APP_NAME	TestLoadFrame
#undef  APP_BASE
#define APP_BASE	TestUIApp


class APP_NAME : public APP_BASE
{
	typedef SHARED_POINTER_TYPE( APP_NAME )		TestLoadFramePtr;

public:
	APP_NAME (IPlatform *platform, EDevice::type deviceType) :
		APP_BASE( platform, deviceType )
	{
	}


	void Update (float dt) override
	{
		TestApp::Update( dt );

		ESS()->GetUserInterface()->GetScreen()->Draw( dt );
		
		ESS()->GetGraphicsEngine()->GetBatchRender()->Flush();
		ESS()->GetGraphicsEngine()->GetBatchRender()->Clear();

		ESS()->GetGraphicsEngine()->SwapBuffers();
	}


	void OnEnter () override
	{
		APP_BASE::OnEnter();

		UIFrameResourcePtr	frame;

		ESS()->GetUserInterface()->GetLocaleManager()->Load( "ui/locale/locale_main.lcs" );
		ESS()->GetUserInterface()->GetLocaleManager()->SetCurrentLanguage( "rus" );

		ESS()->GetUserInterface()->GetActionManager()->AddAction( "Button1.OnClick",
			UIAction( DelegateBuilder::Create( TestLoadFramePtr(this), &APP_NAME::Button1_OnClick ) ) );

		ESS()->GetResourceManager()->Load( EResource::UI_FRAME, "ui/main_menu2.ui", frame );

		ESS()->GetUserInterface()->GetScreen()->ShowFrame( frame->GetWidget() );
	}


	void OnExit () override
	{
		APP_BASE::OnExit();

		ESS()->GetUserInterface()->GetLocaleManager()->Clear();
	}
	

	void Button1_OnClick (Widget *)
	{
		WARNING( "Button1.OnClick" );
	}
};
